package com.jimmy.web.base;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import com.jimmy.web.base.dto.FooRequestDTO;
import com.jimmy.web.base.dto.FooResponseDTO;

@RestController
public class FooController {

    @GetMapping("/foo")
    public String foo() {
        return "Hello Foo, I am Jimmy";
    }

    @PostMapping("/foo/dto")
    public FooResponseDTO handleFooDto(@RequestBody FooRequestDTO request) {
        // 解析参数并处理逻辑
        String details = "Received name: " + request.getName() + ", age: " + request.getAge();
        return new FooResponseDTO("Success", details);
    }

    @GetMapping("/foo/dto/simulate")
    public FooResponseDTO simulateFooDto(@RequestParam String name, @RequestParam int age) {
        // 模拟DTO参数处理
        String details = "Received name: " + name + ", age: " + age;
        return new FooResponseDTO("Success", details);
    }
}
